Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using denton to convert*lower frequency variable to a higher one

    Hi,

    I am struggling to use denton option to convert my annual variables' data to a quarterly one.
    I have a panel data for 10 countries and I have the annual data for fin_freedom for 12 years. I want to use denton to convert this annual fin_freedom to the quarterly for 12 years. I have read all FAQ, help denton etc but couldn't be succeeded to resolve the issue.
    I don't find enough information to follow the complete process of using denton. I have my annual data saved as file IVsY.dta and the new file that I want to save the quarterly data is IVsQ.dta.

    The code that I am using is:

    denton fin_freedom using IVsQ.dta, interp( fin_freedom) from(IVsY.dta) generate(q_FF)

    It gives me error saying IVsY.dta doesnot exist. I have tried every other option to change the name of file with full directory, but I cannot resolve getting denton work.

    Also I don't know which file to open while giving this code, the original file which is saved as IVsY.dta or entirely a new file.....

    Any help would be appreciated.

    Best Regards
    Aamina

  • #2
    I would suggest mipolate (from SSC). I find it much easier than denton (also from SSC) to use and you'll get similar results (See #4 in this thread).

    Comment


    • #3
      Thanks Justin

      Of course mipolate works fine but I would want to use denton as it seems to be a customized short way to do the process. Also it is always good to learn new codes and their usage.


      Best
      Aamina

      Comment


      • #4
        Then I would test your code by opening both IVsQ.dta and IVsY.dta in Stata, then copy the full path from the window for each and paste it into your denton command so you know there aren't any issues with the directory path. I'm guessing here, but perhaps that will address the issue in #1.

        Comment


        • #5
          Dear Justin

          Please see my below example of the data. I want to convert these yearly observations of countries (for two variables financialfreedom and businessfreedom) into quarters using denton.

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input long Country int Year byte financialfreedom float businessfreedom
          1 2002 80   85
          1 2003 80   85
          1 2004 80   85
          1 2005 80   85
          1 2006 90   80
          1 2007 90   80
          1 2008 90   80
          1 2009 80 79.6
          1 2010 80 77.8
          1 2011 80 77.4
          1 2012 80 76.5
          1 2013 80 75.8
          1 2014 80 76.3
          1 2015 80 72.5
          1 2016 80 71.9
          1 2017 80 69.4
          1 2018 80 75.5
          1 2019 80 71.4
          2 2002 30   40
          2 2003 30   40
          2 2004 30   40
          2 2005 10   40
          2 2006 30 58.2
          2 2007 20 59.1
          2 2008 20 56.5
          2 2009 20 62.9
          2 2010 20 59.4
          2 2011 20   65
          2 2012 20 68.5
          2 2013 20   68
          2 2014 30 70.8
          2 2015 30 62.2
          2 2016 30 52.6
          2 2017 30 53.4
          2 2018 30 52.1
          2 2019 30 50.9
          3 2002 30   55
          3 2003 30   55
          3 2004 30   55
          3 2005 30   55
          3 2006 30 39.8
          3 2007 30 40.9
          3 2008 40 60.2
          3 2009 50 64.7
          3 2010 50   65
          3 2011 50 64.5
          3 2012 40 63.8
          3 2013 40 63.3
          3 2014 40 62.7
          3 2015 40 65.4
          3 2016 40 68.3
          3 2017 40 66.8
          3 2018 50 71.5
          3 2019 50 65.9
          4 2002 30   55
          4 2003 30   55
          4 2004 30   55
          4 2005 30   55
          4 2006 30 46.6
          4 2007 40 48.2
          4 2008 40 49.1
          4 2009 40 46.7
          4 2010 40 53.1
          4 2011 40 54.9
          4 2012 40 54.6
          4 2013 50 50.2
          4 2014 60 54.8
          4 2015 60 49.3
          4 2016 60   54
          4 2017 60 49.1
          4 2018 60 57.3
          4 2019 60 69.3
          5 2002 70   70
          5 2003 70   70
          5 2004 70   70
          5 2005 70   70
          5 2006 70   56
          5 2007 60 54.9
          5 2008 60 56.3
          5 2009 60 68.9
          5 2010 60 65.6
          5 2011 60 65.8
          5 2012 60 69.5
          5 2013 60 69.2
          5 2014 60   62
          5 2015 60 59.1
          5 2016 60 64.9
          5 2017 60 63.9
          5 2018 60   63
          5 2019 60 61.8
          6 2002 50   70
          6 2003 50   70
          6 2004 50   70
          6 2005 50   70
          6 2006 50   71
          6 2007 50 70.7
          6 2008 50 68.6
          6 2009 50 67.4
          6 2010 50 65.8
          6 2011 50 64.4
          end
          label values Country Country2
          label def Country2 1 "Bahrain", modify
          label def Country2 2 "Bangladesh", modify
          label def Country2 3 "Egypt", modify
          label def Country2 4 "Indonesia", modify
          label def Country2 5 "Jordan", modify
          label def Country2 6 "Kuwait", modify

          Comment


          • #6
            Where's the dataset with the indicator variable? You'll need to attach that for denton to work. Again, judging by your data there is minimal variability. I go back to my original suggestion of using mipolate:

            Code:
            gen quarter =yq(Year, 2)
            format quarter %tq
            xtset Country quarter
            tsfill
            
            ds *freedom*
            foreach x in `r(varlist)' {
                gen ln_`x' = log(`x')
                mipolate ln_`x' quarter, gen(i`x') pchip by(Country)
                replace i`x' = exp(i`x')
            }

            Comment

            Working...
            X